const getJsonUrlParam = () => {
    //需要先decodeURIComponent 否则 冒号会乱码
    let paramsStr = decodeURI(decodeURIComponent(window.location.search))
    if (paramsStr) {
        let params = paramsStr.substring(1, paramsStr.length);
        let paramArray = params.split("&");
        // let keyParam = paramArray.filter(item => item.startsWith(key));
        let requestObj = new Object()
        if (paramArray && paramArray.length > 0) {
            paramArray.forEach(item => {
                let target = item.split("=");
                try {
                    requestObj[target[0]] = JSON.parse(decodeURI(target[1]))

                }catch (e) {

                }

            })

            return (requestObj);
        }
    }
    return undefined;
}

const getUrlParam = () => {
    //需要先decodeURIComponent 否则 冒号会乱码
    let paramsStr = window.location.search
    if (paramsStr) {
        let params = paramsStr.substring(1, paramsStr.length);
        let paramArray = params.split("&");
        // let keyParam = paramArray.filter(item => item.startsWith(key));
        let requestObj = new Object()
        if (paramArray && paramArray.length > 0) {
            paramArray.forEach(item => {
                let target = item.split("=");
                requestObj[target[0]] = decodeURI(target[1])

            })

            return (requestObj);
        }
    }
    return undefined;
}


export {
    getJsonUrlParam,
    getUrlParam
}